Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Use retain on Packets instead of creating a new one#5804

Merged
sagar-solana merged 2 commits intosolana-labs:masterfrom
sagar-solana:fix_packet_wastage
Sep 6, 2019
Merged

Use retain on Packets instead of creating a new one#5804
sagar-solana merged 2 commits intosolana-labs:masterfrom
sagar-solana:fix_packet_wastage

Conversation

@sagar-solana
Copy link
Copy Markdown
Contributor

Problem

Draining Packet.packets and then assigning them to a new Packets without a recycler was wasteful

Summary of Changes

Collect indices to discard and remove the packets that fail verification.

Unfortunately there doesn't seem to be a pretty way to do this :(

sakridge
sakridge previously approved these changes Sep 5, 2019
Copy link
Copy Markdown
Contributor

@sakridge sakridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, not too pretty, but seems ok. Better than what is there.

@@ -81,28 +81,49 @@ where
let now = Instant::now();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to get rid of the packets.packets.append at some point. I don't think we need to copy into a single vec do we?

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 5, 2019

Codecov Report

Merging #5804 into master will decrease coverage by 13.3%.
The diff coverage is 85.7%.

@@            Coverage Diff            @@
##           master   #5804      +/-   ##
=========================================
- Coverage    75.5%   62.1%   -13.4%     
=========================================
  Files         226     226              
  Lines       41810   50938    +9128     
=========================================
+ Hits        31593   31682      +89     
- Misses      10217   19256    +9039

@sagar-solana
Copy link
Copy Markdown
Contributor Author

@sakridge so @carllin and I took another shot at this. Does this look any better?

@mergify mergify Bot dismissed sakridge’s stale review September 5, 2019 21:06

Pull request has been modified.

@sagar-solana sagar-solana force-pushed the fix_packet_wastage branch 3 times, most recently from 227f0bc to 2d315da Compare September 5, 2019 21:12
// we should be able to automatically drop any packets in the index gaps.
let mut retain_ix = 0;
let mut i = 0;
packets.packets.retain(|_| {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ask and ye shall receive

Comment thread core/src/window_service.rs Outdated
}

#[test]
fn test_recv_window() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test the code path where there are bad shreds that actually get filtered out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, see where I add a bunch of Packet::default()s ?

@sagar-solana sagar-solana merged commit a452249 into solana-labs:master Sep 6, 2019
@sagar-solana sagar-solana deleted the fix_packet_wastage branch September 6, 2019 02:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants